/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2023-08-15 21:48:27
 * @LastEditors: Clark
 * @LastEditTime: 2023-08-16 00:02:14
 * @Description: file content
 */

#include "s3c2440_soc.h"

void sdram_init(void)
{
    BWSCON = 0x22000000;

    BANKCON6 = 0x18001;
    BANKCON7 = 0x18001;

    REFRESH = 0x8404f5;

    BANKSIZE = 0xb1;

    MRSRB6 = 0x20;
    MRSRB7 = 0x20;
}

int sdram_test(void)
{
    volatile unsigned char *p = (volatile unsigned char *)0x30000000;

    // write sdram
    int i = 0;
    for (i = 0; i < 1000; i++)
    {
        p[i] = 0x55;
    }

    // read sdram
    for (i = 0; i < 1000; i++)
    {
        if (0x55 != p[i])
        {
            return -1;
        }
    }

    return 0;
}
